package com.jialiang.base.admin.account.domain.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jialiang.auth.api.constants.PageData;
import com.jialiang.auth.api.constants.PageInfoToPageDataConverter;
import com.jialiang.base.admin.account.domain.mapper.PermissionMapper;
import com.jialiang.base.admin.account.domain.pojo.entity.Permission;
import com.jialiang.base.admin.account.domain.pojo.vo.PermissionListItemVO;
import com.jialiang.base.admin.account.domain.service.IPermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author jialiang
* @description 针对表【account_permission(权限)】的数据库操作Service实现
* @createDate 2024-09-26 10:32:59
*/
@Slf4j
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {

    @Value("${tmall.dao.default-query-page-size}")
    private Integer defaultQueryPageSize;

    @Autowired
    private PermissionMapper permissionMapper;

    public PermissionServiceImpl() {
        log.debug("创建业务类对象：PermissionServiceImpl");
    }


    @Override
    public PageData<PermissionListItemVO> list(Integer pageNum) {
        log.debug("开始处理【查询权限列表】的业务，页码：{}", pageNum);
        PageHelper.startPage(pageNum, defaultQueryPageSize);
        List<PermissionListItemVO> list = permissionMapper.list();
        PageInfo<PermissionListItemVO> pageInfo = new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }

    @Override
    public PageData<PermissionListItemVO> list(Integer pageNum, Integer pageSize) {
        log.debug("开始处理【查询权限列表】的业务，页码：{}，每页记录数：{}", pageNum, pageSize);
        PageHelper.startPage(pageNum, pageSize);
        List<PermissionListItemVO> list = permissionMapper.list();
        PageInfo<PermissionListItemVO> pageInfo = new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }
}




